How to I initialize a class with an interface button clicked? [Objective - C]
Posted
by
seaworthy
on Stack Overflow
See other posts from Stack Overflow
or by seaworthy
Published on 2011-01-18T00:25:03Z
Indexed on
2011/01/18
0:53 UTC
Read the original article
Hit count: 146
I am having a problem with figuring out how to initialize a class with button clicked. The code is listed below the line I have a problem with has "HELP NEEDED HERE" comment above it.
//
// Controller.m
//
#import "Controller.h"
@implementation Controller
- (id)init {
self = [super init];
if(self){
numberTotal = 0;
//HELP NEEDED HERE
[self btnScore_Clicked:(id)sender];
}
return self;}
- (IBAction) btnScore_Clicked:(id)sender {
numberTotal += 1;
NSLog(@"Number Total: %d",numberTotal);
}
- (void)dealloc {
[super dealloc];
}
@end
//
// Controller.h
//
#import <UIKit/UIKit.h>
@interface Controller : UIViewController {
NSInteger numberTotal;
}
- (IBAction) btnScore_Clicked:(id)sender;
@end
Thanks!
© Stack Overflow or respective owner